<template>
	<view>
		<view v-for="room in rooms" style="display: flex;justify-content: space-between;align-items: center;">
			<!-- 卡片体 -->
			<view style="padding: 10px;" @click="onClickRoom(room)">
				<view style="display: flex;justify-content: flex-start;align-items: center;">
					<u-avatar :src="absUrl('/static/avatar.jpg')" size="45"></u-avatar>
					<view style="margin:0 10px;">
						<view style="padding: 5px 0;font-size: 16px;">
							 <span>云谷少侠</span><span>&nbsp;</span><span style="color: limegreen">@麦微</span>
						</view>
						<view style="color: #7d7d7d;font-size: 13px;">
							({{room.id}}){{room.topic}}
						</view>
					</view>
				</view>
			</view>
			
			<view style="margin: 0 10px;padding: 3px 8px;background-color: #e00;border-radius: 100px;color:white">
				3
			</view>
		</view>
	</view>
	
	<tabbs @change="tabChange"></tabbs>
</template>

<script>
	import tabbs from '@/pages/tabbs/tabbas.vue'
	export default {
		components:{tabbs},
		data() {
			return {
				rooms:[]
			}
		},
		async onLoad(options){
			
			let that = this
			setTimeout(async ()=>{
				const userId = that.userStore.baseInfo.id
				console.log(`user ID:${userId}`)
				
				const res = await that.$http.get(`/common/chat/rooms?userId=${userId}`)
					
				that.rooms = res.data
				
				console.log(that.rooms)
				
				that.$chatService.start('chat-client:' + userId)
				
				// that.$refs.paging.reload()
			},500)
			
			// console.log(options)
			// if(options.userId)
			// {

			// }
		},
		methods: {
			onClickRoom(room){
				console.log(room.topic)
				
				uni.navigateTo({
					url:`/pages/job/user/job-state/message?topic=${room.topic}`
				})
			}
		}
	}
</script>

<style>

</style>
